-Znext-solver Ignore region constraints from the nested goals in leakcheck#155749
-Znext-solver Ignore region constraints from the nested goals in leakcheck#155749ShoyuVanilla wants to merge 1 commit intorust-lang:mainfrom
-Znext-solver Ignore region constraints from the nested goals in leakcheck#155749Conversation
-Znext-solver Ignore region constraints from the nested goals in leakcheck
589add8 to
e4719c4
Compare
This comment has been minimized.
This comment has been minimized.
e2650aa to
54588cf
Compare
Canonicalize free regions from inputs as placeholders in root univ Context: The box named *coroutine witness Send lifetime requirements now considered by leakcheck* [this roadmap](https://raw.githubusercontent.com/hexcatnl/roadmap/e380fef94b47c02a056b4c8f05124a9db475b990/next-solver.svg) Fixes (only for the next-solver) #106569 Prerequisite of #155749
Canonicalize free regions from inputs as placeholders in root univ Context: The box named *coroutine witness Send lifetime requirements now considered by leakcheck* [this roadmap](https://raw.githubusercontent.com/hexcatnl/roadmap/e380fef94b47c02a056b4c8f05124a9db475b990/next-solver.svg) Fixes (only for the next-solver) #106569 Prerequisite of #155749
This comment has been minimized.
This comment has been minimized.
54588cf to
29dab0f
Compare
|
r? lcnr |
|
This PR changes a file inside Some changes occurred to the core trait solver cc @rust-lang/initiative-trait-system-refactor changes to the core type system cc @lcnr |
| .for_each(|c| each_edge(c.sub, c.sup)); | ||
| region_constraints.data().constraints[i].0.iter_outlives().for_each( | ||
| |Constraint { kind: _, sub, sup, visible_for_leak_check }| { | ||
| each_edge(sub, sup, visible_for_leak_check) |
There was a problem hiding this comment.
maybe don't even provide any constraints that are not visible to leak hceck to each_edge, feels cleaner to me,
i.e.
| each_edge(sub, sup, visible_for_leak_check) | |
| match visible_for_leak_check { | |
| ty::VisibleForLeakCheck::Yes => | |
| each_edge(sub, sup), | |
| ty::VisibleForLeakCheck::No => {} | |
| } | |
| pub type QueryRegionConstraint<'tcx> = | ||
| (ty::RegionConstraint<'tcx>, ConstraintCategory<'tcx>, ty::VisibleForLeakCheck); |
There was a problem hiding this comment.
not in this PR, but mind adding a FIXME: Convert this into a struct
| // We ignore constraints from the nested goals in leak check. This is to match | ||
| // with the old solver's behavior, which has separated evaluation and fulfillment, | ||
| // and the former doesn't consider outlives obligations from the later. | ||
| let vis = if is_root_goal { |
There was a problem hiding this comment.
why special-case root goals here?
There was a problem hiding this comment.
I thought that we should only ignore region constraints from nested goals and if I mark them as VisibleForLeakCheck::No for root goals as well, they would be so in the InferCtxt outside of the solver and then ignored from the leak check for other goals as well, but after thinking twice, they wouldn't cause universe leaks in other goals anyway 😅 Yeah, so might be okay to remove the spacial casing here
| .into_iter() | ||
| .filter(|&(outlives, _)| seen.insert(outlives)) | ||
| .map(|(outlives, _)| outlives) | ||
| .filter(|&(outlives, _, vis)| seen.insert((outlives, vis))) |
There was a problem hiding this comment.
this may cause us to end up with the same constraint with vis: Yes and vis: No 🤔 I guess it's fine as long as that doesn't cause issues
There was a problem hiding this comment.
I did this deliberately as we could already have the same constraints with different visibilities without this and if that would be the case, the resulting visibility would be order-dependent 🤔
There was a problem hiding this comment.
could eagerly collect into a list, and use a hashmap pointing to the index of the element, on a hit we Or the visibility
| t1, | ||
| r2, | ||
| constraint_category, | ||
| ty::VisibleForLeakCheck::Yes, |
There was a problem hiding this comment.
slightly concerning 🤔
how hard is it to pass VisibleForLeakCheck to here?
There was a problem hiding this comment.
I guess it wouldn't be that hard but I thought visibilities are not real concerns here in borrowck
There was a problem hiding this comment.
they are not 😅 I would love us to somehow defensively guard against this... as rn u need to globally reason about this code for whether it's correct
what do you think you make it into a three-state enum with Yes, No, Unreachable and have the leak_check ICE when encountering Unreachable
There was a problem hiding this comment.
Ah, yes, such global context would be very confusing and fragile to future changes 😅 That would be more desirable 👍
| ty: Ty<'tcx>, | ||
| region: ty::Region<'tcx>, | ||
| category: ConstraintCategory<'tcx>, | ||
| vis: ty::VisibleForLeakCheck, |
There was a problem hiding this comment.
components_must_outlive can always be ty::VisibleForLeakcheck::No/ for TypeOutlives in general 🤔
There was a problem hiding this comment.
I guess they might be decomposed into RegionOutlivesPredicate with component-wise thingy. Would it be okay?
There was a problem hiding this comment.
it matches the old solver which currently never considers type outlives in the leak check 🤔
There was a problem hiding this comment.
but also, we only ever use this in places which won't ever leak check anymore, so 🤷
There was a problem hiding this comment.
Maybe we could try VisibleForLeakCheck::Unreachable here as well?
29dab0f to
cff8c42
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
cff8c42 to
7be9fb6
Compare
View all comments
Fixes rust-lang/trait-system-refactor-initiative#251
Fixes #140577
Fixes #153596